package com.cndw.kungfu.vo.goodsvo;

import com.cndw.kungfu.domain.Goods;
import com.cndw.kungfu.domain.GoodsMode;
import com.cndw.kungfu.model.Context;

/**
 * 物品栏vo对象
 * 
 * @author fantadust
 * 
 */
public class GoodsVO {
	/**
	 * 物品编号
	 */
	private long id;
	/**
	 * 等级
	 */
	private int level;
	/**
	 * 玩家id
	 */
	private long playerId;

	/**
	 * 是否绑定
	 */
	private int binding;
	/**
	 * 来源
	 */
	private int source;
	/**
	 * 堆叠数量
	 */
	private int stackNum;
	/**
	 * 存储位置
	 */
	private int storagePlace;
	/**
	 * 物品基本属性
	 */
	private GoodsModeVO goodsModeVO;
	/**
	 * 物品的装备属性
	 */
	private EquipVO equipVO;
	public GoodsVO(){
		
	}
	
	public GoodsVO(int goodsId,long playerId,int level) {
		initGoodsVO(goodsId,playerId,level,false);
	}
	public GoodsVO(int goodsId,long playerId,int level,boolean luck){
		initGoodsVO(goodsId,playerId,level,luck);		
	}
	private void initGoodsVO(int goodsId,long playerId,int level,boolean luck){
		GoodsMode goodsMode = Context.getGoodsServer().getModeById(goodsId);
		if (goodsMode == null) {
			return ;
		}
		goodsModeVO = new GoodsModeVO(goodsMode);
		if (goodsMode.isEquiq()) {
			equipVO = new EquipVO(level, playerId, goodsMode,luck);
		}
	}
	
	public GoodsVO(GoodsMode goodsMode){
		if (goodsMode == null) {
			return ;
		}
		goodsModeVO = new GoodsModeVO(goodsMode);
		if (goodsMode.isEquiq()) {
			equipVO = new EquipVO(0, 0, goodsMode,false);
		}
	}
	public GoodsVO(Goods goods) {
		if (goods != null) {
			id = goods.getId();
			level = goods.getLevel();
			playerId = goods.getPlayerId();
			binding = goods.getBinding();
			source = goods.getSource();
			stackNum = goods.getStackNum();
			storagePlace = goods.getStoragePlace();
		}
		GoodsMode goodsMode = Context.getGoodsServer().getModeById(goods.getGoodsId());
		if (goodsMode == null) {
			return ;
		}		
		goodsModeVO = new GoodsModeVO(goodsMode);
		if (goodsMode.isEquiq()) {
			equipVO = new EquipVO(goods, goodsMode);
		}
		
	}

	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public long getPlayerId() {
		return playerId;
	}
	public void setPlayerId(long playerId) {
		this.playerId = playerId;
	}
	public int getBinding() {
		return binding;
	}
	public void setBinding(int binding) {
		this.binding = binding;
	}
	public int getSource() {
		return source;
	}
	public void setSource(int source) {
		this.source = source;
	}
	public int getStackNum() {
		return stackNum;
	}
	public void setStackNum(int stackNum) {
		this.stackNum = stackNum;
	}
	public int getStoragePlace() {
		return storagePlace;
	}
	public void setStoragePlace(int storagePlace) {
		this.storagePlace = storagePlace;
	}
	public GoodsModeVO getGoodsModeVO() {
		return goodsModeVO;
	}
	public void setGoodsModeVO(GoodsModeVO goodsModeVO) {
		this.goodsModeVO = goodsModeVO;
	}
	public EquipVO getEquipVO() {
		return equipVO;
	}
	public void setEquipVO(EquipVO equipVO) {
		this.equipVO = equipVO;
	}
}
